<extend name="./Application/Home/View/Layout/application.html"/>
<block name="content">
    <div class="clearsH"></div>

    <div class="all">
        <ul class="menu">
            <li><a href="javascript:void(0);">全部商品</a></li>
            <li><a href="javascript:void(0);" id="list"><i class="fa fa-th"></i></a></li>
        </ul>
    </div>

    <div class="products">
        <volist name="products" id="product">
            <dl>
                <dt><a href="{{:U('show',['id'=>$product[id]])}}"><img class="img-responsive"
                                                                       src="{{$product.thumb}}"
                                                                       alt="商品图片"
                                                                       style="width: 152px;height: 92px;"/></a></dt>
                <dd><a href="#">{{$product.name}}</a><span>已售 {{$product.sale_done}}</span></dd>
                <dd class="label">库存 {{$product.stock}}</dd>
                <dd>¥ {{$product.price}}元</dd>
            </dl>
        </volist>


        <div id="clears"></div>
    </div>
    <div class="perspective" id="loadmore">
        <span class="more">查看更多</span>
    </div>
</block>
<block name="js">
    <script type="text/javascript" src="__PUBLIC__/assets/home/js/jquery.min.js"></script>

    <script>
        $(function () {

            //加载更多
            var nStart = 2;
            $('.more').click(function () {
                var _this = $(".products");
                if (nStart >= "{{$count}}") {
                    //alert('后面没有数据了！');
                    $("#loadmore").text('没有数据了亲...').css({
                        "border-top": "1px solid #d4d5d6",
                        "height": "30px",
                        "line-height": "30px"
                    });
                    return false;
                } else {
                    $.post("{{:U('data')}}", {start: nStart}, function (res) {
                        $.each(res['result'], function (i, item) {
                            _this.append(
                                '<dl>' +
                                '<dt><a href="/Home/Index/show/id/'+item.id+'.html"><img class="img-responsive"' +
                                'src="' + item.thumb + '"' +
                                'alt="商品图片" style="width: 152px;height: 92px;"/></a></dt>' +
                                '<dd><a href="#">' + item.name + '</a><span>已售 '+item.sale_done+'</span></dd>' +
                                '<dd class="label">库存 ' + item.stock + '</dd>' +
                                '<dd>¥ ' + item.price + '元</dd>' +
                                '</dl>'
                            );
                        });
                    });
                    nStart += 2;
                }
            });


        })
    </script>


</block>
